// src/App.jsx
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import { AuthProvider } from './contexts/AuthContext';
import { ProtectedRoute } from './components/ProtectedRoute';

// 页面组件（同方式一）
import Login from './pages/Login';
import InitApp from './pages/InitApp';

function App() {
  return (
    <AuthProvider>
      <Router>
        <Routes>
          {/* 公开路由 */}
          <Route path="/login" element={<Login />} />
        
          {/* 受保护路由：需登录 */}
          <Route path="/" element={<ProtectedRoute element={<InitApp />} />} />

        
          {/* 404 路由 */}
          <Route path="*" element={<Navigate to="/" replace />} />
        </Routes>
      </Router>
    </AuthProvider>
  );
}

export default App;